package com.minelx.datamicroscope.core.index;

import com.minelx.datamicroscope.core.condition.RawCondition;
import com.minelx.datamicroscope.core.query.AliasedKey;
import com.minelx.datamicroscope.core.query.CollectingResource;
import com.minelx.hellopandas.core.PandasMethodProvider;
import io.gitee.minelx.filesystem.Directory;
import com.minelx.statementsplus.cha.base.ChaSession;
import io.gitee.minelx.filesystem.File;

import java.util.List;

class OnlineConditionalIndexFactory implements ConditionalIndexFactory {

	private final PandasMethodProvider pandasMethodProvider;

	private final Directory cacheFilesDirectory;

	private final ChaSession chaSession;

	OnlineConditionalIndexFactory(PandasMethodProvider pandasMethodProvider, Directory cacheFilesDirectory, ChaSession chaSession) {
		this.pandasMethodProvider = pandasMethodProvider;
		this.cacheFilesDirectory = cacheFilesDirectory;
		this.chaSession = chaSession;
	}

	@Override
	public boolean available(String repositoryTablePath) {
		return true; // online index is always available
	}

	@Override
	public Index createIndex(List<AliasedKey> remainingKeys, List<RawCondition> conditions, CollectingResource collectingResource, File destination) {
		return new OnlineIndex(pandasMethodProvider, cacheFilesDirectory, chaSession, remainingKeys, conditions, collectingResource, destination);
	}
}
